import requestInstance from '../index'
import { ILoginInRes, IResData, IAccount } from './type'

enum LoginApi {
  getToken = '/login',
  getUser = '/users/',
  getMenu = '/role/'
}
const getToken = (data: IAccount) => {
  return requestInstance.post<IResData<ILoginInRes>>({
    url: LoginApi.getToken,
    data: data
  })
}

const getUserInfoById = (id: number) => {
  return requestInstance.get<IResData>({
    url: LoginApi.getUser + id
  })
}

const getMenuById = (id: number) => {
  return requestInstance.get<IResData>({
    url: LoginApi.getMenu + id + '/menu'
  })
}

export { getToken, getUserInfoById, getMenuById }
